# $Id: PKGBUILD 151260 2012-02-25 10:17:00Z allan $
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Baptiste Daroussin <baptiste.daroussin@gmail.com>
# Contributor: Grigorios Bouzakis <grbzks[at]gmail[dot]com>
# Contributor: mightyjaym <jm.ambrosino@free.fr>

pkgname=giflib
pkgver=5.0.4
pkgrel=1
pkgdesc="A library for reading and writing gif images"
url="http://sourceforge.net/projects/giflib/"
arch=('i686' 'x86_64' sh4)
license=('MIT')
depends=('libx11')
provides=("libungif=${pkgver}")
conflicts=('libungif')
replaces=('libungif')
options=('!libtool')
source=(http://downloads.sourceforge.net/sourceforge/giflib/${pkgname}-${pkgver}.tar.bz2)

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  sed -i '8 i\
AM_PROG_AR' configure.ac
  sed -i '/AC_PATH_XTRA/d' configure.ac
  sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/' configure.ac
  cp /usr/share/automake-*/config.guess .
  cp /usr/share/automake-*/config.sub .
  libtoolize -f
  autoreconf
  automake --add-missing
  ./configure --prefix=/usr --disable-static
  make

  # libungif compatibility - instructions taken from Redhat specfile
  MAJOR=`echo ${pkgver} | sed 's/\([0-9]\+\)\..*/\1/'`
  gcc -shared -Wl,-soname,libungif.so.${MAJOR} -Llib/.libs -lgif -o libungif.so.${pkgver}
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install

  install -m755 libungif.so.${pkgver} "${pkgdir}/usr/lib/"
  ln -sf libungif.so.${pkgver} "${pkgdir}/usr/lib/libungif.so.4"
  ln -sf libungif.so.4 "${pkgdir}/usr/lib/libungif.so"

  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}
md5sums=('da60935d07374de00a78c2f6f720c8f5')
